﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.TownHall.ServiceClient;
using System.Collections.Generic;

namespace NASA.BeAMartian
{
    public class ClientState
    {

            public Category CurrentCategory { get; set; }
            public Topic CurrentTopic { get; set; }
            public NuggetList CurrentTopicQuestions { get; set; }
            public Nugget CurrentQuestion { get; set; }
            public Tag CurrentTag { get; set; }
            public User CurrentUser { get; set; }
            public ClientState()
            {
                CategoryCache = new CategoryCache();
                CategoryCache.Categories = new CategoryList();
                CategoryTopicCache = new Dictionary<string, TopicCache>();
                TopicQuestionCache = new Dictionary<string, QuestionCache>();
                CurrentCategory = new Category();
                CurrentTopic = new Topic();
                CurrentQuestion = new Nugget();
                CurrentTopicQuestions = new NuggetList();
                CurrentTag = new Tag();
                CurrentUser = new User();
                UserCache = new UserCache();
                Settings = new SettingsCache();
                TagCache = new TagList();

            }
            public TagList TagCache { get; set; }
            public CategoryCache CategoryCache
            { get; set; }
            public Dictionary<string, TopicCache> CategoryTopicCache
            { get; set; }
            public Dictionary<string, QuestionCache> TopicQuestionCache
            { get; set; }
            public UserCache UserCache
            { get; set; }
            public SettingsCache Settings
            { get; set; }
        }
        public class CategoryCache
        {
            private CategoryList _categoryList = new CategoryList();

            public CategoryList Categories
            {
                get { return _categoryList; }
                set
                {
                    _categoryList = value;
                    LastUpdated = DateTime.UtcNow;
                }


            }
            public DateTime LastUpdated { get; set; }
        }

        public class TopicCache
        {
            private TopicList _topicList = new TopicList();
            public TopicCache()
            {
                _topicList = new TopicList();
            }

            public TopicList Topics
            {
                get { return _topicList; }
                set
                {
                    _topicList = value;
                    LastUpdated = DateTime.UtcNow;
                }
            }
            public DateTime LastUpdated { get; set; }
        }
        public class QuestionCache
        {
            private NuggetList _questionList = new NuggetList();
            public QuestionCache()
            {
                _questionList = new NuggetList();
            }
            public NuggetList Questions
            {
                get { return _questionList; }
                set
                {
                    _questionList = value;
                    LastUpdated = DateTime.UtcNow;
                }
            }
            public DateTime LastUpdated { get; set; }
        }
        public class UserCache
        {
            private UserList _userList = new UserList();
            public UserCache()
            {
                _userList = new UserList();
            }
            public UserList Users
            {
                get { return _userList; }
                set
                {
                    _userList = value;
                    LastUpdated = DateTime.UtcNow;
                }
            }
            public DateTime LastUpdated { get; set; }

        }

        public enum LoginType
        {
            UserNamePassword = 1,
            FacebookConnect = 2
        }

        public class SettingsCache
        {
            private int _refreshIntervalMinutes = 5;
            public LoginType LastLoginType { get; set; }
            public string UserName { get; set; }
            public string Password { get; set; }
            public int RefreshIntervalMinutes
            {
                get { return _refreshIntervalMinutes; }
                set { _refreshIntervalMinutes = value; }

            }
            public DateTime LastUpdated { get; set; }
        }

    }

